//
//  LTQStatus.swift
//  WeiBoProject
//
//  Created by MAC on 16/3/2.
//  Copyright © 2016年 LTQ. All rights reserved.
//

import UIKit

//微博数据模型
class LTQStatus: NSObject {
    
    ///id	int64	微博ID
    var id: Int = 0
    
    /// 微博信息内容
    var text: String?
    /// 微博创建时间
    var created_at: String?
    /// 微博来源
    var source: String?
    /// 缩略图配图数组 key: thumbnail_pic
    var pic_urls: [LTQPicture]?
    
    ///reposts_count	int	转发数
    var reposts_count: Int = 0
    ///comments_count	int	评论数
    var comments_count: Int = 0
    ///attitudes_count	int	表态数
    var attitudes_count: Int = 0
    
    /// 用户模型
    var user: LTQStatusUser?
    ///被转发的原微博信息字段
    var retweeted_status: LTQStatus?
    
    
    init(dict: [String: NSObject]) {
        super.init()
        // 如果使用 KVC 时，value 是一个字典，会直接给属性转换成字典
        setValuesForKeysWithDictionary(dict)
        
        if let userDic = dict["user"] as? [String: NSObject]{
            // 获取到 user的字典,然后进行字典转模型
            user = LTQStatusUser(dict: userDic)
            
        }
        
        if let retweetDic = dict["retweeted_status"] as? [String: NSObject]{
            retweeted_status = LTQStatus(dict: retweetDic)
        }
        
        if let pic_URLS = dict["pic_urls"] as? [[String: NSObject]]{
            
            //遍历字典转模型
            pic_urls = [LTQPicture]()
            
            for info in pic_URLS{
                
                pic_urls?.append(LTQPicture(dict: info))
            }
            
            
        }

        
    }

        override func setValue(value: AnyObject?, forUndefinedKey key: String) {}

}